package model.aplicationmodule;

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

import model.aplicationmodule.common.AppModule;

import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.ViewCriteria;
import oracle.jbo.ViewObject;
import oracle.jbo.server.ApplicationModuleImpl;
import oracle.jbo.server.ViewLinkImpl;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Mon Nov 12 16:55:15 ICT 2012
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class AppModuleImpl extends ApplicationModuleImpl implements AppModule {
    /**
     * This is the default constructor (do not remove).
     */
    public AppModuleImpl() {
    }

    /**
     * Container's getter for HoidapLinhvucView1.
     * @return HoidapLinhvucView1
     */
    public ViewObjectImpl getHoidapLinhvucView1() {
        return (ViewObjectImpl)findViewObject("HoidapLinhvucView1");
    }

    /**
     * Container's getter for HoidapLinhVucViewLinks1.
     * @return HoidapLinhVucViewLinks1
     */
    public ViewObjectImpl getHoidapLinhVucViewLinks1() {
        return (ViewObjectImpl)findViewObject("HoidapLinhVucViewLinks1");
    }

    /**
     * Container's getter for HoidapView1.
     * @return HoidapView1
     */
    public ViewObjectImpl getHoidapView1() {
        return (ViewObjectImpl)findViewObject("HoidapView1");
    }

    /**
     * Container's getter for HoidapLinhvucViewLink1.
     * @return HoidapLinhvucViewLink1
     */
    public ViewObjectImpl getHoidapLinhvucViewLink1() {
        return (ViewObjectImpl)findViewObject("HoidapLinhvucViewLink1");
    }

    /**
     * Container's getter for HoidapHoidapLinhvucFkLink1.
     * @return HoidapHoidapLinhvucFkLink1
     */
    public ViewLinkImpl getHoidapHoidapLinhvucFkLink1() {
        return (ViewLinkImpl)findViewLink("HoidapHoidapLinhvucFkLink1");
    }

    /**
     * Container's getter for HoidapViewLinkLinhvuc1.
     * @return HoidapViewLinkLinhvuc1
     */
    public ViewLinkImpl getHoidapViewLinkLinhvuc1() {
        return (ViewLinkImpl)findViewLink("HoidapViewLinkLinhvuc1");
    }

    public void getDmChuDe(String langcode) {
        Date now = new Date();
        Timestamp timestamp = new Timestamp(now.getTime());
        oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(timestamp);

        ViewObject vo = this.getHoidapLinhvucView1();
        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("HoidapLinhvucViewCriteria");
        vc.ensureVariableManager().setVariableValue("varLang", langcode);
        vc.ensureVariableManager().setVariableValue("varNgayhethan",
                                                    jboDate.dateValue().toString());
        vo.getViewCriteriaManager().removeViewCriteria("HoidapLinhvucViewCriteria");
        vo.getViewCriteriaManager().applyViewCriteria(vc);
        vo.executeQuery();
    }

    public void getChudekhac(String langcode, String chudeid) {
        Date now = new Date();
        Timestamp timestamp = new Timestamp(now.getTime());
        oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(timestamp);

        ViewObject vo = this.getHoidapLinhvucView1();
        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("HoidapLinhvucViewCriteria1");
        vc.ensureVariableManager().setVariableValue("varLang", langcode);
        vc.ensureVariableManager().setVariableValue("varNgayhethan",
                                                    jboDate.dateValue().toString());
        vc.ensureVariableManager().setVariableValue("varchudeid", chudeid);
        vo.getViewCriteriaManager().removeViewCriteria("HoidapLinhvucViewCriteria1");
        vo.getViewCriteriaManager().applyViewCriteria(vc);
        vo.executeQuery();
    }
    
    public void getDscauhoi(String chudeid) {
//        ViewObject vo2 = this.getHoidapView1();
//        ViewCriteria vc2 =
//            vo2.getViewCriteriaManager().getViewCriteria("HoidapViewCriteria");
//        vc2.ensureVariableManager().setVariableValue("varIdchude", chudeid);
//        vo2.getViewCriteriaManager().removeViewCriteria("HoidapViewCriteria");
//        vo2.getViewCriteriaManager().applyViewCriteria(vc2);
//        vo2.executeQuery();
    }
    
//    public void getChitietcauhoi(String chudeid) {
//        ViewObject vo = this.getHoidapView1();
//        ViewCriteria vc =
//            vo.getViewCriteriaManager().getViewCriteria("HoidapViewCriteria1");
//        vc.ensureVariableManager().setVariableValue("varId", chudeid);
//        vo.getViewCriteriaManager().removeViewCriteria("HoidapViewCriteria1");
//        vo.getViewCriteriaManager().applyViewCriteria(vc);
//        vo.executeQuery();
//    }
}
